﻿using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Web.Http;
using Common.Logging;
using Learun.Application.Base.SystemModule;
using Learun.Application.Organization;
using Learun.Application.TwoDevelopment.ZZDT_EC;
using Learun.Loger;
using Learun.Util;
using Learun.Util.Operat;
using log4net.Config;

namespace Learun.Application.Web.AppApi
{
    /// <summary>
    /// 设置项（By YuXH）
    /// </summary>
    [RoutePrefix("api/SettingsApi")]
    [HandlerApiLogin(FilterMode.Enforce)]
    public class SettingsApiController : WebApiControllerBase
    {
        #region 模块对象
        private ec_projectSettingsBLL ec_projectSettingsBLL = new ec_projectSettingsBLL();
        #endregion

        /// <summary>
        /// 根据名字拿
        /// </summary>
        /// <param name="settingName"></param>
        /// <param name="projId"></param>
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetList(string projId)
        {
            var res = ec_projectSettingsBLL.GetList(projId);
            return Success(res);
        }
        /// <summary>
        /// 根据名字拿
        /// </summary>
        /// <param name="settingName"></param>
        /// <param name="projId"></param>
        /// <returns></returns>
        [HttpGet]
        public IHttpActionResult GetEntity(string settingName, string projId)
        {
            var res = ec_projectSettingsBLL.GetEntity(settingName, projId);
            return Success(res);
        }

        /// <summary>
        /// 新增或者修改。根据Name来的，id不重要
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="projId"></param>
        /// <returns></returns>
        [HttpPost]
        public IHttpActionResult SaveEntity(ec_projectSettingsEntity entity, string projId)
        {
            ec_projectSettingsBLL.SaveEntity(entity, projId);
            return Success("");
        }

        /// <summary>
        /// 根据id来删除
        /// </summary>
        /// <param name="keyValue"></param>
        /// <param name="projId"></param>
        [HttpPost]
        public IHttpActionResult DeleteEntity(string keyValue, string projId)
        {
            ec_projectSettingsBLL.DeleteEntity(keyValue, projId);
            return Success("");
        }
    }
}